
import { createReducer } from 'redux-immutablejs'
import { fromJS } from 'immutable'
import {
  GET_CART_LIST,SET_TEMP_CART,ADD_CART_INFO
} from '../constants/cart'



export const cartList = createReducer(fromJS([]), {
  [GET_CART_LIST]: (state, action) => {
    return fromJS(action.data)
  }
})

//临时加入购物车的商品（主要记录附属商品）
export const addCartInfo = createReducer(fromJS({}), {
  [ADD_CART_INFO]: (state, action) => {
    return fromJS(action.data)
  }
})

//立即购买的商品
export const tempCart = createReducer(fromJS([]), {
  [SET_TEMP_CART]: (state, action) => {
    return fromJS(action.data)
  }
})